package com.gxa.modules.app.outpatient.selfpay.controller;


import com.gxa.common.utils.Result;
import com.gxa.modules.app.outpatient.selfpay.dto.SelfPaydto;
import com.gxa.modules.app.outpatient.selfpay.service.SelfPayService;
import com.gxa.modules.model.entity.fee.Patient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName PatientContorller
 * @Description
 * @Author Mr.YUAN
 * @Date 2022/11/12 11:33
 */
@RestController
@Api(tags = "自助缴费接口")
@RequestMapping("/selfpay")
public class SelfPayContorller {
    @Autowired
    private SelfPayService selfPayService;

    @GetMapping("/list")
    @ApiOperation("查询就诊人的付费单子")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "就诊人的id",dataType = "int"),
    })
    public Result list(Integer id){
        List<SelfPaydto> selfPaydtos = selfPayService.queryById(id);
        return new Result().ok(selfPaydtos);
    }

    @GetMapping("/pay")
    @ApiOperation("缴费")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "就诊人的id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "appointId",value = "预约的id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "orderMoney",value = "订单金额",dataType = "double"),
//            @ApiImplicitParam(paramType = "query",name = "userId",value = "登录用户的id",dataType = "int"),
//            @ApiImplicitParam(paramType = "query",name = "payPwd",value = "用户支付密码",dataType = "String")
    })
    public Result selfPay(Integer id,Integer appointId,double orderMoney){
        Result result = selfPayService.addOutPayRecords(id, appointId, orderMoney);
        return result;
    }

    @GetMapping("/paylist")
    @ApiOperation("获取门诊缴费记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "orderId",value = "订单号",dataType = "int"),
    })
    public Result selfPaylist(String orderId){
        Result result = selfPayService.queuryPayList(orderId);
        return result;
    }

    @GetMapping("/paylists")
    @ApiOperation("个人中心门诊缴费记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "就诊人id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "startTime",value = "开始时间",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "endTime",value = "结束时间",dataType = "String"),
    })
    public Result selfPaylists(Integer id,String startTime,String endTime){
        Result result = selfPayService.queuryPayLists(id ,startTime,endTime );
        return result;
    }
}